// collect adaptor info
package collector

import (
    "github.com/prometheus/client_golang/prometheus"
    "megacli_exporter/megacli"
)

type adapterCollector struct {
    adapterNum *prometheus.Desc
}

func init() {
    prometheus.MustRegister(NewAdapterCollector())
}

func NewAdapterCollector() prometheus.Collector {
    return &adapterCollector{
        adapterNum: prometheus.NewDesc(
            prometheus.BuildFQName("megacli", "adapter", "total"),
            "adapter total",
            nil, nil,
        ),
    }
}

func (c *adapterCollector) Collect(ch chan<- prometheus.Metric) {
    cs, _ := megacli.GetControllers()
    ch <- prometheus.MustNewConstMetric(c.adapterNum, prometheus.GaugeValue, float64(len(cs)))
}

// Describe returns all descriptions of the collector.
func (c *adapterCollector) Describe(ch chan<- *prometheus.Desc) {
    ch <- c.adapterNum
}
